/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.hslu.prg2.team2.logic;

/**
 * Computer player with a decent logic implemented
 * 
 * @author Claudio
 */
public class RandomComputerPlayer extends ComputerPlayer
{
    public RandomComputerPlayer(String name)
    {
        super(name);
    }
    
    protected int setRandom(INextMove nextMove) {
        int col = -1;
        do {
            double frictionPerCol = 1.0 / nextMove.getColumnCount();
            double random = Math.random();
            col = (int) (random / frictionPerCol);
        } while (!nextMove.isColumnPlayable(col));

        return col;
    }
    
    @Override
    public int playNextDisc(INextMove nextMove)
    {
        return setRandom(nextMove);
    }
    
    @Override
    public String toString()
    {
        return "Einfacher Gegner";
    }
}
